package com.woniu113.junk.commons.model;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;
import java.util.Set;

public class Result<T> {
    private String msg;
    private T data;
    private Integer code;

    private Integer total;

    public String getMsg(){
        return msg;
    }

    public Result<T> setMsg(String msg){
        this.msg=msg;
        return this;
    }

    public Integer getTotal() {
        return total;
    }

    public Result<T> setTotal(Integer total) {
        this.total = total;
        return this;
    }

    public T getData(){
        return data;
    }

    public Result<T> setData(T data){
        this.data=data;
        return this;
    }

    public Integer getCode(){
        return code;
    }

    public Result<T> setCode(Integer code){
        this.code=code;
        return this;
    }

    public static <S> Result<S> getResult(Class<S> type){
        Result<S> result =new Result<>();
        result.setCode(200);
        result.setMsg("访问成功");
        return result;
    }

    public static Result<Object> getResult(){
        Result<Object> result =new Result<>();
        result.setCode(200);
        result.setMsg("访问成功");
        return result;
    }

    public static <S> Result<List<S>> getListResult(Class<S> type){
        Result<List<S>> result =new Result<>();
        result.setCode(200);
        result.setMsg("访问成功");
        return result;
    }
    public static <S> Result<Page<S>> getPageResult(Class<S> type){
        Result<Page<S>> result =new Result<>();
        result.setCode(200);
        result.setMsg("访问成功");
        return result;
    }

    public static <S> Result<Set<S>> getSetResult(Class<S> type){
        Result<Set<S>> result =new Result<>();
        result.setCode(200);
        result.setMsg("访问成功");
        return result;
    }
}
